using UnityEngine;
using System.Collections;

public class CameraFollow : MonoBehaviour {

	public float dampTime = 0.15f;
    private Vector3 velocity = Vector3.zero;
    public Transform target;
 
	void Start()
	{
		//Screen.showCursor = false;
	}
	
    void Update () 
    {
		Vector3 point = camera.WorldToViewportPoint(target.position);
	    Vector3 delta = target.position - camera.ViewportToWorldPoint(new Vector3(0.5f, 0.22f, point.z));
        Vector3 destination = new Vector3(transform.position.x + delta.x, 1, transform.position.z + delta.z);
	 	transform.position = Vector3.SmoothDamp(transform.position, destination, ref velocity, dampTime);
    }
}